"""
演示Python pymysql库的基础操作
"""

from pymysql import Connection
connection = Connection(
    host="localhost", # 主机名
    port=3306, # 端口
    user="root", # 账户
    password="root", # 密码
    autocommit=True
)
# 获取游标
cursor = connection.cursor()
# 选择数据库
connection.select_db("test")
# 执行sql
cursor.execute("insert into pymysql_test values(2, '李四')")
# 通过commit确认
# connection.commit()
# 关闭连接
cursor.close()